import React from 'react'; import { IUserHasId, IPagePopulatedToShowRevision } from '@growi/core'; import { GetServerSideProps, GetServerSidePropsContext, } from 'next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import dynamic from 'next/dynamic'; import Head from 'next/head'; import superjson from 'superjson'; import { useCurrentGrowiLayoutFluidClassName } from '~/client/services/layout'; import { MainPane } from '~/components/Layout/MainPane'; import { ShareLinkLayout } from '~/components/Layout/ShareLinkLayout'; import GrowiContextualSubNavigationSubstance from '~/components/Navbar/GrowiContextualSubNavigation'; import { Page } from '~/components/Page'; import type { PageSideContentsProps } from '~/components/PageSideContents'; import { DrawioViewerScript } from '~/components/Script/DrawioViewerScript'; import { SupportedAction, SupportedActionType } from '~/interfaces/activity'; import { CrowiRequest } from '~/interfaces/crowi-request'; import { RendererConfig } from '~/interfaces/services/renderer'; import { IShareLinkHasId } from '~/interfaces/share-link'; import type { PageDocument } from '~/server/models/page'; import { useCurrentUser, useCurrentPageId, useRendererConfig, useIsSearchPage, useCurrentPathname, useShareLinkId, useIsSearchServiceConfigured, useIsSearchServiceReachable, useIsSearchScopeChildrenAsDefault, useDrawioUri, useIsContainerFluid, } from '~/stores/context'; import loggerFactory from '~/utils/logger'; import { NextPageWithLayout } from '../_app.page'; import { CommonProps, getServerSideCommonProps, generateCustomTitleForPage, getNextI18NextConfig, } from '../utils/commons'; const logger = loggerFactory('growi:next-page:share'); const PageSideContents = dynamic(() => import('~/components/PageSideContents').then(mod => mod.PageSideContents), { ssr: false }); // const Comments = dynamic(() => import('~/components/Comments').then(mod => mod.Comments), { ssr: false }); const ShareLinkAlert = dynamic(() => import('~/components/Page/ShareLinkAlert'), { ssr: false }); const ForbiddenPage = dynamic(() => import('~/components/ForbiddenPage'), { ssr: false }); type Props = CommonProps & { shareLinkRelatedPage?: IShareLinkRelatedPage, shareLink?: IShareLinkHasId, isExpired: boolean, disableLinkSharing: boolean, isSearchServiceConfigured: boolean, isSearchServiceReachable: boolean, isSearchScopeChildrenAsDefault: boolean, drawioUri: string | null, rendererConfig: RendererConfig, }; type IShareLinkRelatedPage = IPagePopulatedToShowRevision & PageDocument; superjson.registerCustom( { isApplicable: (v): v is IShareLinkRelatedPage => { return v != null && v.toObject != null && v.lastUpdateUser != null && v.creator != null && v.revision != null; }, serialize: (v) => { return superjson.stringify(v.toObject()) }, deserialize: (v) => { return superjson.parse(v) }, }, 'IShareLinkRelatedPageTransformer', ); // GrowiContextualSubNavigation for shared page // get page info from props not to send request 'GET /page' from client type GrowiContextualSubNavigationForSharedPageProps = { currentPage?: IPagePopulatedToShowRevision, isLinkSharingDisabled: boolean, } const GrowiContextualSubNavigationForSharedPage = (props: GrowiContextualSubNavigationForSharedPageProps): JSX.Element => { const { currentPage, isLinkSharingDisabled } = props; if (currentPage == null) { return <> } return (
); }; const SharedPage: NextPageWithLayout = (props: Props) => { useCurrentPathname(props.shareLink?.relatedPage.path); useIsSearchPage(false); useShareLinkId(props.shareLink?._id); useCurrentPageId(props.shareLink?.relatedPage._id); useCurrentUser(props.currentUser); useRendererConfig(props.rendererConfig); useIsSearchServiceConfigured(props.isSearchServiceConfigured); useIsSearchServiceReachable(props.isSearchServiceReachable); useIsSearchScopeChildrenAsDefault(props.isSearchScopeChildrenAsDefault); useDrawioUri(props.drawioUri); useIsContainerFluid(props.isContainerFluid); const growiLayoutFluidClass = useCurrentGrowiLayoutFluidClassName(); const isNotFound = props.shareLink == null || props.shareLink.relatedPage == null || props.shareLink.relatedPage.isEmpty; const isShowSharedPage = !props.disableLinkSharing && !isNotFound && !props.isExpired; const shareLink = props.shareLink; const title = generateCustomTitleForPage(props, props.shareLinkRelatedPage?.path ?? ''); const sideContents = shareLink != null ? : <>; // const footerContents = shareLink != null && isPopulated(shareLink.relatedPage.revision) // ? ( // <> // // // ) // : <>; return ( <> {title}
{isShowSharedPage && }
{ props.disableLinkSharing && (
)} { (isNotFound && !props.disableLinkSharing) && (